package com.linkoog.devtools.intellij.ui.table.cell_reander;

import com.intellij.util.ui.JBUI;

import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.table.TableCellRenderer;
import java.awt.*;
import java.io.Serializable;

public class StringTableCellRenderer implements TableCellRenderer, Serializable {


    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        JLabel label = new JLabel();
        label.setOpaque(true);
        label.setName("Table.cellRenderer");

        label.setBorder(JBUI.Borders.empty(1));
        // 设置选中时的背景色
        if (isSelected) {
            label.setBackground(table.getSelectionBackground());
            label.setForeground(table.getSelectionForeground());
        } else {
            label.setBackground(table.getBackground());
            //label.setForeground(table.getForeground());
        }
        label.setText((String)value);
        return label;
    }


}
